<?php
/*
 * Created on Oct 9, 2010
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
 */
?>
<script type="text/javascript">
$(function() {
$("a.ajax-delete").click(function(){
		var delLink = $(this).attr("href");
		var temp = new Array();
		temp = delLink.split('/');
		id = temp[temp.length-1];
		$("#dialog").html('<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>This item will be permanently deleted and cannot be recovered. Are you sure?</p>')
		$("#dialog").dialog({
			title: 'Delete "' + $(this).attr('title') + '"',
			autoOpen: true,
			height: 180,
			buttons: {
				'Delete': function() {
					// Submit delete item
					$.get(delLink, function(){
						alert("You have just removed a record.");
					}, "json");
					$("#"+id).remove();
					$(this).dialog('close');
				},
				Cancel: function() {
					$(this).dialog('close');
				}
			}
		});
		$("#dialog").dialog("open");
		return false;
	});
});
</script>
<div style="text-align: right;">
	<a id="addStore" href="<?=site_url(array("c" => "cms_store", "m" => "add_store"))?>">
		<img src="<?=image_url();?>function/add.gif" width="106" height="31" border="0">
	</a>
</div>
<table id="storeBrowse" class="cont-table-list" cellpadding="5" cellspacing="0" style="width: 100%;">
	<thead>
		<tr>
			<th class="small">Edit</th>
			<th class="small">Delete</th>
			<th>Store Name</th>
			<th>Zip code</th>
			<th>Phone</th>
			<th>Email</th>
		</tr>
	</thead>
	<tbody>
		<?php if(is_array($stores)): $i = 0; $per_page = $this->pagination->cur_page * $this->pagination->per_page; ?>
		<?php foreach($stores as $item): $i++?>
		<tr class="<?= $i%2 ? 'odd' : 'even'?>" id="<?=$item['id']?>">
			<td class="small"><a class="ajax-edit" href="<?=site_url(array("c" => "cms_store", "m" => "edit_store", "id" => $item['id']))?>" title="Edit"><img src="<?=image_url()?>icons/edit.gif" alt="Edit"/></a></td>
			<td class="small"><a class="ajax-delete" href="<?=site_url(array("c" => "cms_store", "m" => "delete_store", "id" => $item['id']))?>" title="Delete"><img src="<?=image_url()?>icons/del.gif" alt="Delete"/></a></td>
			<td id="store_name<?=$item['id']?>"><?=$item['company_name']?></td>
			<td id="store_zipcode<?=$item['id']?>"><?=$item['zipcode']?></td>
			<td id="store_home_phone<?=$item['id']?>"><?=$item['home_phone']?></td>
			<td id="store_email<?=$item['id']?>"><?=$item['email']?></td>
		</tr>
		<?php endforeach;?>
		<?php endif;?>
	</tbody>
</table>
<div id="temp"></div>
<div class="pagination">
<span>Result: <?=$this->pagination->total_rows?> items</span>
<?= $this->pagination->create_links();?>
</div>

